Fitting Functions To Data In R